package com.chujian.framework.echo.aop;

import com.chujian.framework.annotation.echo.UseEcho;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.MethodMatcher;

import java.lang.reflect.Method;

/**
 * 回显切面
 */
@Slf4j
public class EchoMethodMatcher implements MethodMatcher {

    @Override
    public boolean matches(Method method, Class<?> targetClass) {
        UseEcho useEcho = method.getAnnotation(UseEcho.class);
        boolean matched = null != useEcho;
        if (matched) {
            log.debug("EchoMethodMatcher回显装配 class:{} method:{} matched:{}", targetClass.getName(), method.getName(), method);
        }
        return matched;
    }

    @Override
    public boolean isRuntime() {
        return false;
    }

    @Override
    public boolean matches(Method method, Class<?> targetClass, Object... args) {
        throw new UnsupportedOperationException();
    }
}
